<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/Welcome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片 -->
    <el-card class="box-card">
      <!-- 分栏间隔 -->
      <el-row :gutter="10">
        <el-col :span="12">
          <div class="grid-content bg-purple">
            <!-- 搜索与添加 -->
            <div>
              <el-input placeholder="请输入内容" v-model="orders.query">
                <el-button
                  slot="append"
                  icon="el-icon-search"
                  @click="searchorders()"
                ></el-button>
              </el-input>
            </div>
          </div>
        </el-col>
        <!-- 添加 -->
      </el-row>
      <!-- table栏 -->
      <el-table :data="ordersList" border style="width: 100%">
        <el-table-column type="index" label="#" width="50"> </el-table-column>
        <el-table-column prop="order_number" label="订单编号" width="550">
        </el-table-column>
        <el-table-column prop="order_price" label="订单价格" width="100">
        </el-table-column>

        <el-table-column prop="pay_status" label="是否付款" width="100">
          <template slot-scope="scope">
            <!-- {{ scope.row.order_pay }} -->
            <el-tag type="success" v-if="!scope.row.order_pay">已付款</el-tag>
            <el-tag type="danger" v-else>未付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="is_send" label="是否发货" width="100">
        </el-table-column>
        <el-table-column prop="create_time" label="下单时间" width="200">
          <template slot-scope="scope">
            {{ scope.row.create_time | dateFormat }}
          </template>
        </el-table-column>
        <el-table-column prop="address" label="操作">
          <template slot-scope="scope">
            <!-- 修改 -->
            <el-button
              type="primary"
              icon="el-icon-edit"
              size="mini"
            ></el-button>
            <!-- 查询物流 -->
            <el-button
              type="success"
              icon="el-icon-location"
              size="mini"
              @click="selectkuaidi(scope.row)"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @current-change="handleCurrentChange"
        :page-size="orders.pagesize"
        layout="total, prev, pager, next"
        :total="total"
        background
      >
      </el-pagination>
    </el-card>

    <!-- 物流的弹框 -->
    <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
      <!-- 信息 -->
      <el-timeline :reverse="reverse">
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :timestamp="activity.timestamp"
        >
          {{ activity.content }}
        </el-timeline-item>
      </el-timeline>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>
<script>
import http from '../util/http'
export default {
  data () {
    return {
      // 查询的input值
      orders: {
        query: '',
        pagesize: 5, // 每一页显示多少条数据
        pagenum: 1 // 当前页码
      },
      //   数据源
      ordersList: [],
      //   总共多少条数据
      total: 0,
      // 物流的弹框
      dialogVisible: false,
      //   物流的
      reverse: true,
      //   物流信息数据
      activities: []
    }
  },
  mounted () {
    this.getOrders()
  },
  methods: {
    //   获取数据
    getOrders () {
      http({
        url: 'orders',
        params: this.orders
      }).then((res) => {
        console.log(res.data.data)
        this.total = res.data.data.total
        this.ordersList = res.data.data.goods
      })
    },
    //   查询
    searchorders () {},
    // 查询快递
    selectkuaidi () {
      http('kuaidi/1106975712662').then((res) => {
        console.log(res)
      })
      this.dialogVisible = true
    },
    // 分页
    handleCurrentChange (val) {
      this.orders.pagenum = val
      this.getOrders()
    }
  }
}
</script>
